package com.vencent.spring.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * 修改bean的定义， 比如配置文件中${}获取值，就需要实现BeanFactoryPostProcessor的postProcessBeanFactory方法
 * @author 1d
 *
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor{

	public MyBeanFactoryPostProcessor() {
		// TODO Auto-generated constructor stub
		super();
		System.out.println("----容器级接口----");
		System.out.println("MyBeanFactoryPostProcessor的构造方法");
	}
	
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		// TODO Auto-generated method stub
		System.out.println("----容器级接口----");
		System.out.println("MyBeanFactoryPostProcessor的postProcessBeanFactory方法");
		BeanDefinition bf = beanFactory.getBeanDefinition("person");
		System.out.println("BeanDefinition.getPropertyValues()值为" + bf.getPropertyValues().toString());
		bf.getPropertyValues().addPropertyValue("name", "vencent");
	}

}
